#pragma once


#include "../EngineTFT/Application/iuFramework.h"
#include "../EngineTFT/System/iuOSWindows.h"
#include "../EngineTFT/System/SFOSInformation.h"

#pragma comment( lib, "../Depend/EngineTFT.lib" )


Pure::System::OS::iuOSWindows gOSWindows;
Pure::iuFramework* gFramework = 0;
SFOSInformation os;


LRESULT CALLBACK WinProc( HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam );


int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow )
{
	gOSWindows.Checking();

	if( os.CheckOS() )
	{
		gFramework = new Pure::iuFramework( hInstance, WinProc );	
	}


    MSG message;

    while( GetMessage( &message, 0, 0, 0 ) )
    {
        TranslateMessage( &message );
        DispatchMessage( &message );
    }


	if( gFramework )
	{
		delete gFramework;
		gFramework = 0;
	}


    return (int)message.wParam;
}


LRESULT CALLBACK WinProc( HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam )
{
    switch( message )
    {
	case WM_CREATE :
		return 0;

	case WM_PAINT :
		{
			char buffer[256];
			memset( buffer, 0, sizeof( buffer ) );

			PAINTSTRUCT ps;
			HDC hdc;


			hdc = BeginPaint( hWnd, &ps );

			strcpy_s( buffer, sizeof( buffer ), os.m_strOSInfo.c_str() );
			TextOut( hdc, 20, 20, buffer, strlen( buffer ) );

			EndPaint( hWnd, &ps );
		}
		return 0;

    case WM_DESTROY :
        {
            PostQuitMessage( 0 );
        }
        return 0;
    }      


    return ( DefWindowProc( hWnd, message, wParam, lParam ) );
}